package com.czk.durant.springframework.context.support;

import com.czk.durant.springframework.beans.factory.ConfigurableListableBeanFactory;
import com.czk.durant.springframework.beans.factory.support.DefaultListableBeanFactory;
import com.czk.durant.springframework.exception.BeanException;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/6/21 11:08
 */
public abstract class AbstractRefreshableApplicationContext extends AbstractApplicationContext{
    private DefaultListableBeanFactory beanFactory;

    @Override
    protected void refreshBeanFactory() throws BeanException {
        DefaultListableBeanFactory beanFactory = createBeanFactory();
        loadBeanDefinitions(beanFactory);
        this.beanFactory = beanFactory;
    }

    private DefaultListableBeanFactory createBeanFactory() {
        return new DefaultListableBeanFactory();
    }

    protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory);


}
